---
title: Load provider services and service contracts
summary: Loads service-code assignments and service contracts for a provider location, with offset-windowed contract filtering.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-21
library: SAIF.Business.View.Provider
reference_type: embedded
operation_id: OP-12
trigger: clsProviderLocation.Services / ServiceContracts navigation
---

# Load provider services and service contracts

Loads a provider location's service-code assignments and its service contracts (restricted by an offset window), decorating each contract that has a plan ID with MCO plan details.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-12 |
| **Trigger** | `clsProviderLocation.Services` / `ServiceContracts` navigation |
| **Inputs** | `IDataPortalInfo`, provider-location ID, optional offset in days (default 721) |
| **Outputs** | `clsProviderServiceList`, `clsProviderServiceContractList` |
| **Primary components** | `clsProviderServiceList..ctor`, `clsProviderServiceContractList..ctor` |
| **Entry point** | `SAIF.Business.View.Provider/clsProviderServices.vb:59`; `SAIF.Business.View.Provider/clsProviderServiceContract.vb:199` |

## Steps

1. Services: join [PROVIDER_SERVICE](../database-tables.md#provider_service) to [PROVIDER_SERVICE_CODE](../database-tables.md#provider_service_code) on `:ProviderLocationID` ([SQL-PSVC-01](../sql/SQL-PSVC-01-provider-services.md)).
2. Service contracts: query [PROVIDER_SERVICE_CONTRACT](../database-tables.md#provider_service_contract) on `:ProviderLocationID` ([SQL-PSVC-02](../sql/SQL-PSVC-02-provider-service-contracts.md)).
   - If `inOffset > 0` (default 721 days): additionally restrict to `exp_date is null or exp_date > (sysdate - :Offset)` ([BR-PSVC-001](../business-rules.md#br-psvc-001-service-contracts-are-limited-to-the-offset-window)), ordered by `eff_date desc`.
   - If `inOffset <= 0`: no expiry restriction is applied.
3. Each contract with a non-blank plan ID is decorated with its `MCOPlanInfo` via `SetPlan`, which enforces [BR-MCO-001](../business-rules.md#br-mco-001-mco-plan-must-match-the-assigned-plan-id) (throws on plan-ID mismatch).

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Caller request]) --> S1{Services or contracts?}
	S1 -->|Services| S2["Join PROVIDER_SERVICE to<br>PROVIDER_SERVICE_CODE"]
	S1 -->|Contracts| S3["Query<br>PROVIDER_SERVICE_CONTRACT"]
	S2 --> S4["Bind ProviderLocationID,<br>execute"]
	S3 --> S5{Offset > 0?}
	S5 -->|Yes| S6[Restrict to exp_date null<br>or exp_date > sysdate - Offset]
	S5 -->|No| S7[No expiry restriction]
	S6 --> S8["Bind ProviderLocationID +<br>Offset, execute"]
	S7 --> S8
	S4 --> EndOk1(["clsProviderServiceList<br>returned"])
	S8 --> S9{Contract has plan ID?}
	S9 -->|Yes| S10[SetPlan attaches MCOPlanInfo]
	S9 -->|No| EndOk2(["clsProviderServiceContractList<br>returned"])
	S10 --> EndOk2
```

## Failure and edge-case behavior

- No matching rows for either query: an empty list is returned.
- A contract's plan ID that does not match the plan already assigned raises `ApplicationException("MCO plan submitted does not match plan assigned.")` ([BR-MCO-001](../business-rules.md#br-mco-001-mco-plan-must-match-the-assigned-plan-id)).
- An offset of zero or less removes the expiry-window restriction on service contracts entirely ([BR-PSVC-001](../business-rules.md#br-psvc-001-service-contracts-are-limited-to-the-offset-window)).

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)

## Sources
- `SAIF.Business.View.Provider/clsProviderServices.vb`
- `SAIF.Business.View.Provider/clsProviderServiceContract.vb`
